<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
	<link rel="stylesheet" type="text/css" href="css/loginRegister.css"/>
	<title>教务处-登录</title>
</head>
<body id="panel">
	<form name="form1" id="aaa">
		<p id="message"></p>
		<p>
			<input type="text" name="yhm" placeholder="账号"/>
		</p>
		<p>
			<input type="password" name="pwd" placeholder="密码"/>
		</p>
		<p>
			<input type="button" value="登录" id="login"/>
			<input type="hidden" name="action" value="login" readonly="readonly">
		</p>
		<p>
			<a href="#" id="left">手机短信登录</a>
			<span id="right">
				<a href="#">忘记密码</a>
			</span>
		</p>
	</form>
</body>
<script type="text/javascript" src="js/jquery-1.8.0.js" ></script>
<script type="text/javascript">
$(function(){
	function doLogin(){
		var data = {
			yhm: form1.yhm.value,
			pwd: form1.pwd.value
		};

		var data = $("#aaa").serialize();

		$.getJSON("/jiaowuchu/UserServlet",data,function(user){
			if(null != user && "" != user){
				if(user.yhsf == 0){
					location = "/jiaowuchu/admin.html";
				}else if (user.yhsf==1){
					location = "/jiaowuchu/teacher.html";
				}else {
					location="/jiaowuchu/student.html";
				}
			}else{
				$("#message").html("用户名或密码错误");
				setInterval(function (){
					$("#message").html("");
				},3000)
			}
		});
	}
	
	$("#login").click(function(){
		doLogin();
	});
	
	//判断如果按下Enter回车键，则登录
	$(document).keydown(function(e){
		e = e || window.event
		if(e.keyCode == 13){//Enter键对应键值为13
			doLogin();
		}
	});
	
});
</script>
</html>
